<template>
	<view class="attention" v-if="bodyShow">
		<view class="contact-img">
			<image src="../../static/contact_img.jpeg" mode="widthFix">
		</view>
		<!-- <image class="attention-image" :src="code" v-if="code"/> -->
		<text class="attention-text" @click="setClipboardData" v-if="wechat">联系电话：<text class="attention-wehcat">{{wechat}}</text>点击联系客服</text>
		<text class="attention-text" v-if="desc">{{desc}}</text>
	</view>
</template>

<script>
	import config from '../../src/config/api.config.js';
	import request from '../../src/utils/request.js';
	import userCheck from '../../src/utils/user.js';
	export default {
		data() {
			return {
				parentOpenid: '',
				openid: '',
				localtionPlatform: '',
				bodyShow: false, // 页面显示
				code: '', // 二维码
				desc: '' ,// 描述
				wechat:'',//客服微信号
			}
		},
		onLoad(options) {
			const that = this;
			this.parentOpenid = options.parentOpenid != undefined ?options.parentOpenid:'';
			this.localtionPlatform = userCheck.PlatformType;
			userCheck.checkSession(function(openid){
				that.openid = openid;
				that.getData();
			},this.parentOpenid);
			
		},
		methods: {
			// 获取数据
			async getData() {
				const r = await request({
					url: `${config.API}api/getWechatSub`,
				});
				if (r.error_code === 0) {
					this.code = r.data.img;
					this.desc = r.data.desc;
					this.wechat = r.data.wechat;
					console.log(this.wechat)
					this.bodyShow = true;
				}
			},
			setClipboardData(){
				// uni.setClipboardData({
				//   data: this.wechat,
				//   success(res) {
				//     console.log(`微信号复制成功`);
				// 	uni.showToast({
				// 		title: '微信号复制成功，请添加我们的客服吧！'
				// 	});
				//   },
				//   fail(res) {
				//     console.log(`微信号复制失败`);
				// 	uni.showToast({
				// 		title: '微信号复制失败'
				// 	});
				//   },
				// });
				
				uni.makePhoneCall({
				  phoneNumber: this.wechat //仅为示例，并非真实的电话号码
				})
			}
		}
	}
</script>

<style>
	page {
		height: 100%;
	}
</style>

<style lang="scss" scoped>
	.attention {
		display: flex;
		width: 100%;
		height: 100%;
		flex-direction: column;
		align-items: center;
		
		.contact-img{
			width: 100%;
			display: block;
			image {
				display: block;
				width: 100%;
			}
		}
		
		.attention-image {
			width: 300rpx;
			height: 300rpx;
			margin-top: 40%;
			
		}
		.attention-text {
			font-size: 36rpx;
			font-weight: bold;
			margin-top: 50rpx;
			text-align: center;
			.attention-wehcat {
				color:red;
				padding-right: 8rpx;
			}
		}
	}
</style>
